package com.zhu.transaction.controller;

import org.springframework.http.HttpStatus;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @author byosoft
 * @createtime 2021/3/8-8:55
 */
@ControllerAdvice
public class ErrorController {

    @ExceptionHandler(value = {Exception.class})
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public String allExceptionHand(Exception e, Model model) {
        model.addAttribute("message", e.getMessage());
        model.addAttribute("messageDetail", e.getCause());
        return "common/error";
    }

}
